package com.stockz.scanner.screen;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.core.util.ListUtil;
import com.stockz.scanner.screen.configuration.ConsolidationScreenConfiguration;
import com.stockz.ui.swing.charting.display.indicator.StandardDeviation;

public class ConsolidationScreen implements Screen<ConsolidationScreenConfiguration> {
	private ConsolidationScreenConfiguration configuration = new ConsolidationScreenConfiguration();
	
	@Override
	public ConsolidationScreenConfiguration getConfiguration() {
		return configuration;
	}

	@Override
	public int getMandatorySpan() {
		return configuration.getStandarDeviationSpan();
	}

	@Override
	public boolean isMatch(List<Bar> barList) {
		double values[] = StandardDeviation.values(ListUtil.convert(barList, BarValueType.CLOSE, configuration.getStandarDeviationSpan()), configuration.getStandarDeviationSpan());
		for(double v : values){
			if(v > configuration.getBoundPercentage()){
				return false;
			}
		}
		return true;
	}

}
